package cn.dao.imp;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import cn.dao.ConfigurationDao;
import cn.entity.Configuration;

public class ConfigurationDaoImp extends HibernateDaoSupport implements ConfigurationDao {
	@Override
	public void insertOrUpdate(Configuration config) {
		getHibernateTemplate().saveOrUpdate(config);
	}
	
	@Override
	public void delete(Integer id) {
		Configuration config=new Configuration();
		config.setId(id);
		getHibernateTemplate().delete(config);

	}
	
	@Override
	public void update(Configuration config) {
		getHibernateTemplate().update(config);
	}

	@Override
	public List query(Configuration config) {
		return getHibernateTemplate().find("from Configuration c where c.name=?",config.getName());
	}

	@Override
	public List getAll() {
		return getHibernateTemplate().find("from Configuration");
	}
	
	@Override
	public Configuration getConfigurationById(Integer id) {
		return getHibernateTemplate().get(Configuration.class,id);
	}

	@Override
	public Configuration getStatusByStatusCode(String code) {
		// TODO Auto-generated method stub
		return (Configuration)getHibernateTemplate().find("from Configuration where name='订单状态' and value2='"+code+"'").get(0);
	}

	//根据关键字类型获取全部关键字
	@Override
	public List<Configuration> getStatusByStatusType(String type) {
		return getHibernateTemplate().find("from Configuration where name='"+type+"'");
	}
}
